import request from '../utils/request'
import md5 from 'js-md5'

export function login(username, password) {
  return request({
    url: '/user-api/employee/mobile/login',
    method: 'post',
    data: {
      mobile: username,
      password: md5(password)
    }
  })
}

// user-center api
const newlogin = (param = {}) => {
  return request({
    url: '/user-center/security/user/login',
    method: 'post',
    data: param
  })
}

const kickToken = (param = {}) => {
  return request({
    url: '/user-center/kickToken',
    method: 'post',
    data: param
  })
}

const authorities = (param = {}) => {
  return request({
    url: '/user-center/security/user/authorities',
    method: 'post',
    data: param
  })
}

const clearAllToken = (param = {}) => {
  return request({
    url: '/user-center/clearToken',
    method: 'get'
  })
}

const changeUser = (param = {}) => {
  return request({
    url: '/user-center/loginOutApp',
    method: 'post',
    data: param
  })
}

export {
  newlogin, // 用户登录
  authorities, // 用户权限查询(按应用角色汇总)
  clearAllToken, // 注销 所有token
  changeUser // 根据userId,appId注销下线
}
